package hu.elte.inf.holiuml.model;

import hu.elte.inf.holiuml.coordgeom.CGPoint;
import hu.elte.inf.holiuml.coordgeom.LineSegment;

import java.awt.Graphics;
import java.io.Serializable;
import java.util.Vector;

/**
 * @author Csaba Hoch
 */
public class RelationEdge extends Edge {

	private Relation relation;
	private ClassNode nodeBegin = null;
	private ClassNode nodeEnd = null;

	public RelationEdge() {
	}
	
	public RelationEdge(RelationEdge relationEdge) {
		this.relation = new Relation(relationEdge.getRelation());
		this.nodeBegin = new ClassNode((ClassNode)relationEdge.getNodeBegin());
		this.nodeEnd = new ClassNode((ClassNode)relationEdge.getNodeEnd());
	}

	public void setRelation(Relation relation) {
		this.relation = relation;
	}

	public Relation getRelation() {
		return relation;
	}

	@Override
	//@javax.xml.bind.annotation.XmlIDREF
	public ClassNode getNodeBegin() {
		return nodeBegin;
	}

	@Override
	//@javax.xml.bind.annotation.XmlIDREF
	public ClassNode getNodeEnd() {
		return nodeEnd;
	}

	@Override
	public void setNodeBegin(Node nodeBegin) {
		this.nodeBegin = (ClassNode) (nodeBegin);
	}

	@Override
	public void setNodeEnd(Node nodeEnd) {
		this.nodeEnd = (ClassNode) (nodeEnd);
	}

	@Override
	public Vector<String> getTextVector() {
		if (relation != null) {
			Vector<String> v = new Vector<String>();
			v.add(relation.getRoleBegin());
			v.add(relation.getMultiBegin());
			v.add(relation.getName());
			v.add(null);
			v.add(relation.getRoleEnd());
			v.add(relation.getMultiEnd());
			return v;
		} else {
			return null;
		}
	}
}
